package com.bi.onlineEducation.web.controller;

import com.bi.onlineEducation.annotation.WebProcess;
import com.bi.onlineEducation.domain.CommentInfoPo;
import com.bi.onlineEducation.service.CommentInfoService;
import com.bi.onlineEducation.utils.ResultCode;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Author: chenYuTao
 * @Time: 2022/1/6 15:44
 * @Description: 基础数据控制层
 **/
@RestController
@Api(tags = "评论信息控制层", description = "评论信息数据接口")
public class CommentInfoController {

    @Resource
    private CommentInfoService commentInfoService;

    @ApiOperation("查询所有")
    @WebProcess
    @GetMapping(value = "/commentInfo/findAll")
    public ResultCode findAll() {
        return ResultCode.success(commentInfoService.findAll());
    }

    @ApiOperation("根据id查询评论信息")
    @WebProcess
    @GetMapping(value = "/commentInfo/findById")
    public ResultCode findById(@RequestParam("id") Integer id) {
        return ResultCode.success(commentInfoService.findById(id));
    }

    @ApiOperation("保存信息")
    @WebProcess
    @PostMapping(value = "/commentInfo/save")
    public ResultCode save(@RequestBody CommentInfoPo commentInfoPo) {
        return ResultCode.success(commentInfoService.save(commentInfoPo));
    }

    @ApiOperation("根据id删除评论信息")
    @WebProcess
    @DeleteMapping(value = "/commentInfo/deleteById")
    public ResultCode deleteById(@RequestParam("id") Integer id) {
        return ResultCode.success(commentInfoService.deleteById(id));
    }


}